package 周赛;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class 向字符串添加空格 {
    public String addSpaces(String s, int[] spaces) {
        StringBuilder sb = new StringBuilder();
        int start = 0;
        for(int i=0;i<spaces.length;i++){
            sb.append(s.substring(start,spaces[i]));
            sb.append(' ');
            start = spaces[i];
        }
        //添加[start,s.length())
        sb.append(s.substring(start));
        return sb.toString();
    }
}
